package com.ujiuye.Servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ujiuye.entity.Student;
import com.ujiuye.service.StudentService;
import com.ujiuye.service.impl.StudentServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/studentServlet")
public class StudentServlet extends BaseServlet{
    StudentService ss=new StudentServiceimpl();

    protected void getSearch(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String content=request.getParameter("content");
        List<Student> list = ss.getSearch(content);
        System.out.println(list);
        ObjectMapper mapper=new ObjectMapper();
        String json=mapper.writeValueAsString(list);
        PrintWriter out=response.getWriter();
        out.print(json);
        out.close();
    }
}
